package com.mac.hosp_pre.handler;

import com.mac.hosp_pre.util.JwtUtil;

@FunctionalInterface
public interface RefreshTokenHandler {

    void refreshToken(String loginRedisKey, long expiration,Object userInfo);

    default void beforeHandler(boolean isAdmin,String token,long expiration,Object userInfo,RefreshTokenHandler after) {
        String loginRedisKey = "";
        if (isAdmin){
            loginRedisKey = JwtUtil.getAdminLoginRedisKey(token);
        }else {
            loginRedisKey = JwtUtil.getPortalLoginRedisKey(token);
        }
        after.refreshToken(loginRedisKey,expiration,userInfo);
    }
}
